import Vue from 'vue'
import Router from 'vue-router'
const home = resolve => require(['./views/home.vue'], resolve)
const loading = resolve => require(['./views/loading.vue'], resolve)
const confirm = resolve => require(['./views/confirm.vue'], resolve)
const result = resolve => require(['./views/result.vue'], resolve)
Vue.use(Router)

let router = new Router({
  routes: [
    {
      path: '/',
      redirect: {
        name: 'home'
      }
    },
    {
      // 海报页
      path: '/home',
      name: 'home',
      component: home
    },
    {
      // 加载页
      path: '/loading',
      name: 'loading',
      component: loading
    },
    {
      // 确认页
      path: '/confirm',
      name: 'confirm',
      component: confirm,
      meta: {
        needResult: true
      }
    },
    {
      // 结果页
      path: '/result',
      name: 'result',
      component: result,
      meta: {
        needResult: true
      }
    }
  ]
})

router.beforeEach((to, from, next) => {
  next()
})

export default router
